﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AgentPartOrderEdit.aspx.cs" Inherits="IHISCETeim.Web.AgentSys.PWMgr.AgentPartOrderEdit" %>

<div class="pageContent AgentPartOrderEdit<%=action %>">
	<form method="post" action="PWMgr/AgentPartOrderEdit.aspx?action=<%=action %>&OrderId=<%=OrderId %>" class="pageForm required-validate" onsubmit="return validateCallback(this, navTabAjaxDone);" >
		<div class="pageFormContent" layoutH="56">
                <h2 style=" padding:0px 0px 5px 6px; border-bottom:1px solid #B8D0D6;">1.基本信息</h2>
                    <div style="width:760px">
			            <p>
				            <label>品 情 号：</label>
				            <input name="OrderNumber" type="text" class="" readonly value="" />
			            </p>
			            <p>
				            <label>发行日期：</label>
				            <input name="IssueDate" class="required date" format="yyyy-MM-dd HH:mm" type="text" value="" alt=""/>
			            </p>
                    </div>
                    <div class="divider"></div>
                    <div style="float:left; width:760px" class="uwarrantycardInfoAgentPartOrderEdit<%=action %>"> 			           
                        <p>
				            <label>机号：</label>
				            <input id="AgentPartOrderEdit<%=action %>SerialNumber" name="SerialNumber" class="required" type="text"  value="" alt=""/>
			            </p>
                         <p>
				            <label>经 销 商：</label>
                            <input name="AgentName" type="text" readonly class="required textInput" value="" />
			            </p>
                         <p>
				            <label>机型：</label>
				            <input name="MachineType" class="" type="text"  value="" alt=""/>
			            </p>
                        <p>
				            <label>用户：</label>
				            <input name="CustomerName" class="required" type="text"  value="" alt=""/>
			            </p>
                         
                        <p>
				            <label>工作小时：</label>
				            <input name="WorkHour" class="required" type="text"  value="0" alt=""/>
			            </p>
                            <p>
				            <label>地点：</label>
				            <input name="IntoAddress" class="" type="text"  value="" alt=""/>
			            </p>
                          <p>
				            <label>故障日：</label>
				            <input name="FaultDate" class="date required" format="yyyy-MM-dd HH:mm" type="text"  value="" alt=""/>
			            </p>
                        <p>
				            <label>用户手机：</label>
				            <input name="CustomerMobile" class="required" type="text"  value="" alt=""/>
			            </p>
                 </div>
         
                <h2 style=" padding:0px 0px 5px 6px; border-bottom:1px solid #B8D0D6; clear:both; margin-top:15px;">2.配件明细(只有填写配件号的行才会被保存)</h2>                    
                    <table class="list"  style="width:100%" >
                       <thead>
                         <tr>                                    
                                    <th width="150px">配件号</th>
                                    <th>配件名</th>
                                    <th >数量</th>
                                    <th>类别</th>
                                    <th >运输方式</th>

                                    <th >折后单价(含税)</th>
                                    <th>行金额<th> 
                          </tr>                                
                        </thead>
                        <tbody>
                        <asp:repeater id="rpParts" runat="server">                    
                            <ItemTemplate>
                                 <tr>                                  
                                     <td>
                                         <input type="text" name="ItemCode" id="dwz.AgentPartOrderEdit<%=action %>.ItemCode<%# Eval("ID") %>" class=""  showinputid="rpParts_Dscription_AgentPartOrderEdit<%=action %><%# Eval("ID") %>" autocompletehref="<%=AgentAutoCompleteUrl %>?ajaxmethod=getoitmlist&showtype=102" swidth="300" value="<%# Eval("ItemCode") %>" />
                                         <a class="btnLook" href="/MachineSys/SAPItemListLookUp.aspx?inputtag=<%# Eval("ID") %>" lookupgroup="AgentPartOrderEdit<%=action %>" maxable="false" width="600" resizable="false" title="选择配件">
                                            <hi:text key="查找带回" />
                                        </a>
                                        
                                     </td>
                                     <td>
                                          <input type="text" id="dwz.AgentPartOrderEdit<%=action %>.ItemName<%# Eval("ID") %>"  name="Dscription" value="<%# Eval("Dscription") %>"/>
                                     </td>
                                     <td><input type="text" name="Quantity" value="<%# Eval("Quantity") %>"/></td>
                                     <td>
                                         <select name="BuyType">
                                             <option value="库存订货" <%# Eval("BuyType").ToString()=="库存订货"?"selected":"" %>>库存订货(8.5折)</option>
                                             <option value="紧急订货" <%# Eval("BuyType").ToString()=="紧急订货"?"selected":"" %>>紧急订货(9折)</option>
                                         </select>                                                                              
                                     </td>
                                      <td>
                                         <select name="ShipType">
                                             <option value="汽运" <%# Eval("ShipType").ToString()=="汽运"?"selected":"" %>>汽运</option>
                                             <option value="中铁" <%# Eval("ShipType").ToString()=="中铁"?"selected":"" %>>中铁</option>
                                             <option value="空运" <%# Eval("ShipType").ToString()=="空运"?"selected":"" %>>空运</option>
                                             <option value="随车/随货" <%# Eval("ShipType").ToString()=="随车/随货"?"selected":"" %>>随车/随货</option>
                                         </select>                                                                              
                                     </td>
                                     <td><input type="text" name="Price" readonly value="<%# Eval("Price") %>"/></td>
                                     <td><input type="text" name="LineTotal" readonly value="<%# Eval("LineTotal") %>"/></td>
                                    
                                 </tr>
                             </ItemTemplate>                           
                        </asp:repeater>
                        </tbody>
                      </table>                
              
                <h2 style=" padding:0px 0px 5px 6px; border-bottom:1px solid #B8D0D6; clear:both; margin-top:15px;">3.收货信息</h2>       
                <div style="padding:5px 0px; margin-bottom:5px;">
                            <p>
				                <label>收件人：</label>
				                <input name="AcceptName" class="" type="text"  value="" alt=""/>
			                </p>
                            <p>
				                <label>联系电话：</label>
				                <input name="AcceptTel" class="" type="text"  value="" alt=""/>
			                </p>
                          <div style="clear:both;"></div>
				            <label>收货地址：</label>
				            <input  name="AcceptAddress" class="" type="text" size="100"  value="" alt=""/>
			   </div>
            
                <h2 style=" padding:0px 0px 5px 6px; border-bottom:1px solid #B8D0D6; clear:both; margin-top:15px;">4.申请说明：</h2>
                <div style="padding:5px 0px; margin-bottom:5px;">
                   
				          <label>申请说明：</label>
                          <input name="Remark" type="text"  size="150"   />
			                        
                    <div style="clear:both; padding:10px 10px 10px 35px;">
                        <div style="float:left; top:0px;left:0px; height:210px; width:250px; margin-bottom:20px;">
                             <input type="text" readonly style="width:200px" value="1.机号" />   
                             <a href="<%=getImgPath(obj.JHImg)  %>" class="AgentPartOrderEditImgShow"><img  id="AgentPartOrderEdit<%=action %>imgShow1" src="<%= getImgPath(obj.JHImg) %>"  Width="200" Height="150"/>  </a>                                                                 
                             <div style="clear:both;margin-bottom:2px;"></div>                                   
                             <input type="file" name="filedata" id="AgentPartOrderEdit<%=action %>upload1" uploadify="uploadify" clientId="AgentPartOrderEdit<%=action %>imgShow1,AgentPartOrderEdit<%=action %>imgRelatively1" dirtype="4" foldername="<%=User.Department %>" onUploadSuccess="onAgentPartOrderEdit<%=action %>UploadImgSuccess" fileTypeDesc="只能上传图片" fileTypeExts="*.jpg;*.gif;*.jpeg;*.png;*.bmp" fileSizeLimit="1MB"/>
                            
                             <input type="hidden"  id="AgentPartOrderEdit<%=action %>imgRelatively1" name="JHImg" value="<%= getImgPath(obj.JHImg) %>" />
                                                
                        </div>
                        <div style="float:left;top:0px;left:260px; height:210px; width:250px; margin-bottom:20px;">
                             <input type="text" readonly style="width:200px" value="2.工时" />  
                             <a href="<%=getImgPath(obj.GSImg)  %>" class="AgentPartOrderEditImgShow"> <img  id="AgentPartOrderEdit<%=action %>imgShow2" src="<%= getImgPath(obj.GSImg) %>"  Width="200" Height="150"/></a>                                                                   
                             <div style="clear:both;margin-bottom:2px;"></div>                                   
                             <input type="file" name="filedata" id="AgentPartOrderEdit<%=action %>upload2" uploadify="uploadify" clientId="AgentPartOrderEdit<%=action %>imgShow2,AgentPartOrderEdit<%=action %>imgRelatively2" dirtype="4" foldername="<%=User.Department %>" onUploadSuccess="onAgentPartOrderEdit<%=action %>UploadImgSuccess" fileTypeDesc="只能上传图片" fileTypeExts="*.jpg;*.gif;*.jpeg;*.png;*.bmp" fileSizeLimit="1MB"/>
                            
                             <input type="hidden"  id="AgentPartOrderEdit<%=action %>imgRelatively2" name="GSImg" value="<%= getImgPath(obj.GSImg) %>" />
                                                
                        </div>
                        <div style="float:left;top:250px;left:0px; height:210px; width:250px; margin-bottom:20px;">
                             <input type="text" readonly style="width:200px" value="3.更换前照片" />  
                             <a href="<%=getImgPath(obj.ChangeBeforImg)  %>" class="AgentPartOrderEditImgShow"> <img  id="AgentPartOrderEdit<%=action %>imgShow3" src="<%= getImgPath(obj.ChangeBeforImg) %>"  Width="200" Height="150"/>     </a>                                                              
                             <div style="clear:both;margin-bottom:2px;"></div>                                   
                             <input type="file" name="filedata" id="AgentPartOrderEdit<%=action %>upload3" uploadify="uploadify" clientId="AgentPartOrderEdit<%=action %>imgShow3,AgentPartOrderEdit<%=action %>imgRelatively3" dirtype="4" foldername="<%=User.Department %>" onUploadSuccess="onAgentPartOrderEdit<%=action %>UploadImgSuccess" fileTypeDesc="只能上传图片" fileTypeExts="*.jpg;*.gif;*.jpeg;*.png;*.bmp" fileSizeLimit="1MB"/>
                            
                             <input type="hidden"  id="AgentPartOrderEdit<%=action %>imgRelatively3" name="ChangeBeforImg" value="<%= getImgPath(obj.ChangeBeforImg) %>" />
                                        
                        </div>
                        <div style="float:left;top:250px;left:26px; height:210px; width:250px; margin-bottom:20px;">
                            <input type="text" readonly style="width:200px" value="4.更换后照片" />  
                             <a href="<%=getImgPath(obj.ChangeAfertImg)  %>" class="AgentPartOrderEditImgShow"> <img  id="AgentPartOrderEdit<%=action %>imgShow4" src="<%= getImgPath(obj.ChangeAfertImg) %>"  Width="200" Height="150"/></a>                                                                   
                             <div style="clear:both;margin-bottom:2px;"></div>                                   
                             <input type="file" name="filedata" id="AgentPartOrderEdit<%=action %>upload4" uploadify="uploadify" clientId="AgentPartOrderEdit<%=action %>imgShow4,AgentPartOrderEdit<%=action %>imgRelatively4" dirtype="4" foldername="<%=User.Department %>" onUploadSuccess="onAgentPartOrderEdit<%=action %>UploadImgSuccess" fileTypeDesc="只能上传图片" fileTypeExts="*.jpg;*.gif;*.jpeg;*.png;*.bmp" fileSizeLimit="1MB"/>
                            
                             <input type="hidden"  id="AgentPartOrderEdit<%=action %>imgRelatively4" name="ChangeAfertImg" value="<%= getImgPath(obj.ChangeAfertImg) %>" />                
                        </div>
                    </div>
                      <%if (obj.OrderState != "")
                          { %>
                    <div style="clear:both; padding:5px 5px 5px 5px; border-top:solid 1px #ccc;">
                          <label>申请再确认要求说明：</label>
                          <input name="ReCheckRemark" type="text"  size="150"   />
                    </div>
                    <%} %>
                </div>  
		</div>
		<div class="formBar">
			<ul>
                <input type="hidden" id="AgentPartOrderEdit<%=action %>ajaxmethod" name="ajaxmethod" value="" />
                <%if (HasPower(IHISCETeim.Web.Permission.新增)){ %>
                    <%if (obj.OrderState == "") { %>
                    <li  ><div class="buttonActive"><div class="buttonContent"><button type="submit" onclick="return onAgentPartOrderEdit<%=action %>Add()"> 提交订单 </button></div></div></li>
                    <%} %>	
                 <%if (obj.OrderState == "再确认") { %>
                    <li  ><div class="buttonActive"><div class="buttonContent"><button type="submit" onclick="return onAgentPartOrderEdit<%=action %>Add()"> 再确认提交 </button></div></div></li>
                    <%} %>
                <%} %>

                <%if (HasPower(IHISCETeim.Web.Permission.修改)){ %>
                  <%if (obj.OrderState != "") { %>
                    <li  ><div class="buttonActive"><div class="buttonContent"><button type="submit"  onclick="return onAgentPartOrderEdit<%=action %>Update()"> 修改 </button></div></div></li>
                 <%} %>	
                     <%if (obj.OrderState == "审核中") { %>
                    <li ><div class="buttonActive"><div class="buttonContent"><button type="submit"  onclick="return onAgentPartOrderEdit<%=action %>Confrim()"> 通过审核 </button></div></div></li>
                    <li ><div class="buttonActive"><div class="buttonContent"><button type="submit"  onclick="return onAgentPartOrderEdit<%=action %>ReConfrim()">申请再确认 </button></div></div></li>
                    <li ><div class="buttonActive"><div class="buttonContent"><button type="submit" onclick="return onAgentPartOrderEdit<%=action %>Cancel()"> 取消订单 </button></div></div></li>
                    <%} %>
                <%} %>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">关闭</button></div></div>
				</li>
			</ul>
		</div>
	</form>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $("a.AgentPartOrderEditImgShow").fancybox();
        $("#AgentPartOrderEdit<%=action %>SerialNumber").blur(function () {
            onrefreAgentPartOrderEdit<%=action %>SerialNumberSerialNumberClick();
        });


        var $Qltyjson = eval(<%= Newtonsoft.Json.JsonConvert.SerializeObject(obj)%>);
        //alert($Qltyjson.QltyId)
        var $dateColumn = "IssueDate,IntoDate,FaultDate"
        for (var itm in $Qltyjson) {
            var $val = $Qltyjson[itm];
            if ($dateColumn.indexOf(itm) >= 0){
                //$val = formatterdate($Qltyjson[itm]);
                $val = $Qltyjson[itm].replace("T", " ").substring(0,16);
            }
            if ($(".AgentPartOrderEdit<%=action %>").find("[name='" + itm + "']").is(":checkbox"))
                $(".AgentPartOrderEdit<%=action %>").find("[name='" + itm + "']").attr("checked", $val);
            else
                $(".AgentPartOrderEdit<%=action %>").find("[name='" + itm + "']").val($val);

        }
    })

    function onrefreAgentPartOrderEdit<%=action %>SerialNumberSerialNumberClick()
    {
        var $data = {};
        var $this = $("#AgentPartOrderEdit<%=action %>SerialNumber");
        $data["SerialNumber"] = $this.val();
        var url = "/AgentSys/ajaxDone.ashx?ajaxmethod=getuwarrantycard"
        $.ajax({
            type: 'post',
            url: url,
            data: $data,
            async: false,
            cache: false,
            dataType: 'json',
            success: function (json) {
                if (json.UWCID <= 0) {
                    alertMsg.warn('此机号还没有保修卡信息.相关客户信息请手工填写');
                    //$("#AddAgentQlty2_BtnSave").find("button").attr("disabled", "disabled");
                    return;
                }
               
                for (var itm in json) {
                    if (itm == "IntoDate") {
                        $(".uwarrantycardInfoAgentPartOrderEdit<%=action %>").find("[name='" + itm + "']").val(formatterdate(json[itm]));
                    }
                    else {
                        $(".uwarrantycardInfoAgentPartOrderEdit<%=action %>").find("[name='" + itm + "']").val(json[itm]);
                    }

                }
            }
        });
    }
    function onAgentPartOrderEdit<%=action %>UploadImgSuccess(file, data, response) {
        if (!response)
            return false;
        data = eval("(" + data + ")");
        if (!data.uploadResult) {
            alert(data.errMsg);
            return;
        }
        var $imgUploadPath = data.filePath;
        var $trageIds = data.customerInfo.split(",");
        $("#" + $trageIds[0]).attr("src", $imgUploadPath);
        $("#" + $trageIds[1]).val($imgUploadPath);

       // alert($imgUploadPath)
       // alert( $trageIds[1])
    }
  
    
    //新增时需要处理 金额是否与合同金额一致
    function validateCallbackAgentQltyEdit(form, callback) {
        var $form = $(form);

        $("#AgentQltyEdit_BtnSave").find("button").attr("disabled", "disabled").html("请稍侯......");
        setTimeout(function () { $("#AgentQltyEdit_BtnSave").find("button").removeAttr("disabled").html(" 提 交 "); }, 5000);

        return validateCallback(form, callback);
    }

    function onAgentPartOrderEdit<%=action %>Add()
    {
        if(confirm("你确认要提交此订单吗?")){
            $("#AgentPartOrderEdit<%=action %>ajaxmethod").val("add");
            return true;
        }
        else
            return false;
    }
    function onAgentPartOrderEdit<%=action %>Confrim()
    {
        if(confirm("你确认要通过此订单的审批吗?")){
            $("#AgentPartOrderEdit<%=action %>ajaxmethod").val("edit");
            return true;
        }
        else
            return false;
    }
     function onAgentPartOrderEdit<%=action %>ReConfrim()
    {
         if(confirm("你确认要提交此订单的再确认吗?")){
            $("#AgentPartOrderEdit<%=action %>ajaxmethod").val("recheck");
            return true;
        }
        else
            return false;
     }
    function onAgentPartOrderEdit<%=action %>Cancel()
    {
        if(confirm("你确认要取消此订单吗?")){
            $("#AgentPartOrderEdit<%=action %>ajaxmethod").val("cancel");
            return true;
        }
        else
            return false;
    }

    function onAgentPartOrderEdit<%=action %>Update()
    {
     if(confirm("你确认要修改此订单吗?")){
            $("#AgentPartOrderEdit<%=action %>ajaxmethod").val("update");
            return true;
        }
        else
            return false;
    }
</script>
